﻿/// <reference path="../Extension.js" />
/// <reference path="../Default.js" />

$(document).ready(function () {
    $('.Accordion').accordion({
        autoHeight: false,
        navigation: true,
        collapsible: true,
        active: false
    });

    $("#tLojas").jqGrid({
        datatype: 'json',
        url: '/Operadores/Lojas',
        mtype: 'GET',
        colNames: ['', 'Id', 'Codigo', 'Descrição'],
        colModel: [
            { name: "actions", formatter: "actions", editable: false, sortable: false, resizable: false, fixed: true, align: 'center', width: 26, "formatoptions": { keys: false, editbutton: false, delbutton: true} },
            { name: 'ID_LJOP', index: 'ID_LJOP', width: 80, sortable: false, align: 'right', search: false, hidden: true },
            { name: 'COD_LOJA', index: 'COD_LOJA', width: 80, sortable: false, align: 'right', search: false },
            { name: 'NOME_LOJA', index: 'NOME_LOJA', width: 600, align: 'left', searchoptions: { sopt: ['cn', 'eq']} }
        ],
        gridComplete: function () { loadInputs(); },
        pager: '#pLojas',
        height: 'auto',
        width: 500,
        rowNum: 5,
        rowList: [5, 10, 15, 20],
        sortname: 'COD_LOJA',
        sortorder: "asc",
        autowidth: false,
        viewrecords: true,
        viewsortcols: true,
        gridview: true,
        multiselect: false,
        editurl: '/Operadores/LojaDelete',
        postData: {
            ID_OPER: function () { return $('#ID_OPER').val(); }
        }
    }).navGrid("#pLojas", {
        edit: false, add: false, del: false, search: false, refresh: true
    }).navButtonAdd("#pLojas", {
        caption: '',
        buttonicon: 'ui-icon-circle-plus',
        onClickButton: function () {
            jqGridEdit(
                'Editar Lojas do Operador',
                'tLojas',
                null,
                '/Operadores/LojaUpdate',
                '/Operadores/LojaUpdate',
                null,
                null,
                'LojaEditForm',
                null,
                null,
                null,
                null,
                '&ID_OPER=' + $('#ID_OPER').val()
            );
        },
        title: "adicionar loja",
        position: "last"
    });
});